package ssdb

import (
	"github.com/seefan/gossdb"
	"reflect"
)

//添加映射
// @client 连接对象
// @dataName 数据库名
func DataBaseMapping(pool *gossdb.Connectors) *GoSSDBContent {
	return &GoSSDBContent{pool: pool}
}

//集合上下文
type GoSSDBContent struct {
	pool *gossdb.Connectors
}

//获取集合仓储
// entity 结构体
func (s *GoSSDBContent) GetGoSSDBRepository(entity interface{}) IGoSSDBRepository {
	var entityName string
	typeOfCat := reflect.TypeOf(entity)
	if typeOfCat.Kind() == reflect.Ptr {
		entityName = typeOfCat.Elem().Name()
	}else {
		entityName = typeOfCat.Name()
	}
	return &GoSSDBRepository{
		pool:       s.pool,
		entityName: entityName,
	}
}
